Create a separate datasource.ts file for the TypeORM CLI that does not depend on the NestJS app module. Generate migrations with migration:generate, apply with migration:run, and roll back with migration:revert. Never use synchronize: true in production — use migrations exclusively.
Never use synchronize: true in production — it can drop columns and tables destructively.
Keep a separate datasource.ts for the TypeORM CLI so it works independently of the NestJS app module.
Always implement down() — rollbacks are critical for safe deployments and hotfixes.
Commit all migration files to version control — they are the source of truth for schema history.
Use migrationsRun: true in the NestJS TypeORM config to auto-apply pending migrations on startup.